<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //1、普通格式
        var p={"name":"张三","age":23,"gender":true};
        //使用for in循环遍历取值
        for(var key in p)
            alert(key+":"+p[key]);

        //2、{}嵌套[]
        var persons={"persons":[
                {"name":"张三","age":23,"gender":true},
                {"name":"李四","age":24,"gender":true},
                {"name":"王五","age":25,"gender":false}
            ]
        };
        for(var key in persons)
        {
            for(var i=0;i<persons[key].length;i++)
            {
                for(var keys in persons[key][i])
                {
                    alert(keys+":"+persons[key][i][keys]);
                }
            }
        }
        //3、[]嵌套{}
        var person=[
            {"name":"张三","age":23,"gender":true},
            {"name":"李四","age":24,"gender":true},
            {"name":"王五","age":25,"gender":false}];

        for(var i=0;i<person.length;i++)
        {
            var p0=person[i];
            for(var key in p0)
            {
                alert(key+":"+p0[key]);
            }
        }
    </script>
</head>
<body>

</body>
</html>